package com.smartwebx.ha.web.gis.module.screen;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.smartwebx.ha.dal.usebean.SimpleStatGroup;
import com.smartwebx.ha.dal.usebean.SuperStatGroup;

public class TemplateTextScreen extends BasicScreen {
	@Autowired
	private LayerRainfallScreen layerRainfallScreen;

	/**
	 * 获得全省全年面雨量(需要添加根据站群查找面雨量 by zx)
	 * 
	 * @param bTm(2010-03-22)
	 * @param eTmv(2014-08-22)
	 * @param type(雨量100)
	 * @return
	 * @throws ParseException
	 */
	public double getYearPreRain(Date bTm, Date eTm, String type)
			throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Calendar cal = Calendar.getInstance();
		cal.setTime(bTm);
		int year = cal.get(Calendar.YEAR);
		String bgnTm = year + "-01-01";
		String endTm = year + "-12-31";
		
		List<SuperStatGroup> superStatGroupList = layerRainfallScreen
				.getLayerRainfall(sdf.parse(bgnTm), sdf.parse(endTm));
		double stcdValue = 0d;
		for (SuperStatGroup superStatGroup : superStatGroupList) {
			for (SimpleStatGroup simpleStatGroup : superStatGroup
					.getSimpleStatGList()) {
				if (simpleStatGroup.getAstcd().equals("32000000")) {
					stcdValue = simpleStatGroup.getValue();
				}
			}
		}
		return stcdValue;
	}

}
